<!--
* description:外呼弹窗
* author: zxuan
* createdDate: 2019-11-12
-->
<template>
  <section class="outCall">
    <el-dialog v-dialogDrag
      :close-on-click-modal="false"
      :title="textMap[popupsState]"
      :append-to-body="true"
      :visible.sync="curPopupsVisible"
      @close="sendCode"
      width="1000px"
    >
      <dialogHeader
        slot="title"
        :title="textMap[popupsState]"
        :styleType="$store.state.app.dialogType"
      ></dialogHeader>
      <div class="filter-container filter-params">
        <el-row :gutter="26">
          <component
            v-for="comp in tableComponents.filter(o => o.isMust === true)"
            :ref="comp.isRequire ? comp.isRequire+ comp.compKey : comp.compKey"
            :validrule="comp.validrule"
            :key="comp.compKey"
            :codeField="comp.codeField"
            :textField="comp.textField"
            :popupsKey="comp.compKey"
            :is="comp.component"
            :isMul="comp.isMul"
            :code="formField[comp.codeField]"
            :text="formField[comp.textField]?formField[comp.textField]:''"
            @changeCode="getComponentCode"
            @focusCode="getFocusCode"
            :disabled="comp.disabled"
            :isRequire="comp.isRequire"
            :span="comp.span || 8"
            :dateType="comp.dateType"
            :labelName="comp.labelName"
            :lookuptype="comp.lookuptype"
            :dateOptionsType="comp.dateOptionsType"
          ></component>
        </el-row>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button
          v-for="comp in tableButtons"
          :key="comp.compKey"
          :type="comp.type"
          @click="comp.clickEvent"
        >{{comp.text}}</el-button>
      </div>
    </el-dialog>
  </section>
</template>
<script>
import { formMixins } from "@/components/mixins/formMixins";
import { crmApis } from "@/api/apiList/crm";
import OneTableTemplate from "@/components/templates/popupsOneTable";
export default {
  // 组件混入对象
  mixins: [formMixins],
   components: {
    dialogHeader: () => import("@/components/dialogHeader") //弹窗标题
  },
  data() {
    return {
     curPopupsVisible:false,
      // 保存API配置对象
      apiConfig: crmApis,
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey3",
          type: "primary",
          size: "small",
          clickEvent: () => this.call(),
          text: "外呼",
          position: "bottom"
        }
      ],
      // 动态组件-查询条件
      tableComponents: [
        {
          compKey: "compKey1",
          labelName: "客户名称",
          codeField: "custName",
          component: () => import("@/components/crm/textbox/crmTextInput"),
          isRequire:true,
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey2",
          labelName: "电话",
          codeField: "phone",
          component: () => import("@/components/crm/textbox/crmTextInput"),
          isRequire:true,
          type: "inputText",
          isMust: true
        }
      ],
      // 标题
      textMap: {
        edit: "外呼",
        add: "外呼"
      },
      // 表单数据（无需赋值，由混入对象赋值）
      formField: {
        custName: "",
        phone: ""
      },
    };
  },
  methods: {
    //保存
    call() {
      const that = this;
      // if (that.$utils.isEmpty(that.formField.vin)) {
      //   that.$message({
      //     message: "请选择VIN码",
      //     type: "warning",
      //     duration: 2000
      //   });
      //   return;
      // }

      //保存表单

      //剔除中台不需要的参数，同时不影响弹窗的显示值
      //this.saveForm();
    }
  }
};
</script>
